<template>
  <div class="login">
    <div class="loginin">
      <div class="head">shoppingApp</div>
      <p>一个帐号玩转所有会员服务</p>
      <van-form @submit="onSubmit">
        <van-field
          v-model="username"
          name="用户名"
          label="用户名"
          placeholder="邮箱/手机号"
          :rules="[{ required: true, message: '请填写用户名' }]"
        />
        <van-field
          v-model="password"
          type="password"
          name="密码"
          label="密码"
          placeholder="密码"
          :rules="[{ required: true, message: '请填写密码' }]"
        />
        <div style="margin-top: 16px;">
          <van-button
            round block type="info"
            native-type="submit"
            style='border-radius: 5px;font-size:18px;'
          >登录</van-button>
        </div>
      </van-form>
      <p style="font-size:16px;"><a href="">短信验证码登录</a>|<a href="">重置密码</a></p>
      <p style="font-size:14px;margin-top:30px;">从这里出发，开启生态世界 <a href="" style="margin:0;" @click="jumpRegister()">立即注册</a></p>
      <van-divider
        :style="{ color: '#666', borderColor: '#666', padding: '0 16px' }"
      >
        猜你喜欢
      </van-divider>
      <div class="icon">
        <i class="iconfont">&#xe73e;</i>
        <i class="iconfont">&#xe619;</i>
        <i class="iconfont">&#xe607;</i>
      </div>
      <p>语言：简体中文 国家/地区：中国</p>
      <p>客服电话：1 010 9000</p>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Login',
  data () {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    onSubmit (values) {
      // 触发 store 中的 action
      const result = this.$store.dispatch('loginAsync', values)
      // console.log(result)
      // console.log('result:', result)
      // 登录成功后，跳转到个人中心页面
      result.then(data => {
        if (data.loginSuccess) {
          this.$router.push('/mine')
        }
      })
    },
    jumpRegister () {
      this.$router.push('/register')
    }
  }
}
</script>

<style lang="scss" scoped>
.iconfont{
  font-family:"iconfont" !important;
  font-size:16px;font-style:normal;
  -webkit-font-smoothing: antialiased;
  -webkit-text-stroke-width: 0.2px;
  -moz-osx-font-smoothing: grayscale;}

@font-face {
  font-family: 'iconfont';  /* Project id 2790324 */
  src: url('//at.alicdn.com/t/font_2790324_leicqr79z5a.woff2?t=1630763402222') format('woff2'),
       url('//at.alicdn.com/t/font_2790324_leicqr79z5a.woff?t=1630763402222') format('woff'),
       url('//at.alicdn.com/t/font_2790324_leicqr79z5a.ttf?t=1630763402222') format('truetype');
}


.login{
  height: 100%;
  background: #fff;
}
.loginin{
  margin: 0 auto;
  width: 90%;
  .head{
    font-weight: 900;
    text-align: center;
    color: #1989fa;
    font-size: 36px;
    margin: 0 auto;
    display: block;
    width: 240px;
    height: 70px;
    padding-top: 40px;
  }
  p{
    display: block;
    width: 100%;
    text-align: center;
    font-size: 12px;
    margin: 20px auto;
    color: #999;
    a{
      color: #1989fa;
      margin: 0 30px;
    }
  }
  .icon{
    display: flex;
    justify-content: space-between;
    padding: 0 20px ;
    i{
      display: block;
      font-size: 40px;
      color: #1989fa;
    }
  }
  .p1{
    margin: 20px 0;
    font-size: 12px;
    color: #999;
    hr{
      width: 200px;
      height: 0;
      border: 1px solid #ccc;
    }
    display: flex;
    justify-content: space-between;
  }
}
.van-cell{
  border-bottom: 1px solid #d3d3d3;
  color: #d3d3d3;
}
</style>
